<?php
/**
 * @Author:      zh
 * @DateTime:    2016-02-25 10:45:32
 * @Description: erp 耗材分类
 */
class DataSupplyClassification extends Eloquent
{
    protected $connection = 'mysql_data';
    protected $table = "supply_classification";


    /**
     * @Author   lyt                      <ahlyt@anhuibj.com>
     * @DateTime 2018-01-03T15:28:18+0800
     * @param    [type]                   $st_classifi_id     [description]
     * @return   [type]                                       [description]
     */
    public static function getClassification($st_classifi_id){
    	if(Cache::has('supply_classification_'.$st_classifi_id)){//如果有缓存的 标准耗材
            return Cache::get('supply_classification_'.$st_classifi_id);
        }else{
	        $si_arr=DataSupplyClassification::leftJoin("supply_classification as sc2","sc2.id","=","supply_classification.parent_id")
	        ->leftJoin("supply_classification as sc","sc.id","=","sc2.parent_id")
	        ->where('supply_classification.id',$st_classifi_id)
	        ->select("sc2.id as two_id","sc2.name as two","sc.id as one_id","sc.name as one","sc.is_sale as one_is_sale")->first();
	        if($si_arr){
                Cache::add('supply_classification_'.$st_classifi_id,$si_arr, 10);
            }
	        return $si_arr;
	    }
    
    }
}